﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Transfer : MonoBehaviour {

    private static float rollerStep = 0.08f; 

    public GameObject board;
    public GameObject roller;
    public GameObject foot;

    public float length = 8f;
    public float width = 0.44f;
    public float height = 1;
    public float inclineAngle = 0;

    private List<GameObject> rollersList;
    private List<GameObject> boardsList;
    private List<GameObject> footsList;

	// Use this for initialization
	void Start () {
        rollersList = new List<GameObject>();
        boardsList = new List<GameObject>();
        footsList = new List<GameObject>();

        Mesh mesh = board.GetComponent<Mesh>();

        Instance();
    }

    #region 改变外观

    private void Instance()
    {
        GameObject gameObject;

        for (int i = 0; (i * 0.8f) < length; i++)
        {
            gameObject = Translate(Instantiate(board), 0, 0, i * -rollerStep);
            gameObject.transform.parent = this.transform;
            boardsList.Add(gameObject);
        }

        gameObject = Instantiate(foot);
        gameObject.transform.parent = this.transform;
        footsList.Add(gameObject);
        gameObject = Translate(Instantiate(foot), 0, 0, -(length - 3 * rollerStep));
        gameObject.transform.parent = this.transform;
        footsList.Add(gameObject);

        for (int i = 0; (i + 1) * rollerStep < length; ++i)
        {
            gameObject = Translate(Instantiate(roller), 0, 0, -rollerStep * i);
            gameObject.transform.parent = this.transform;
            rollersList.Add(gameObject);
        }
    }

    #endregion

    private GameObject Translate(GameObject gameObject,float x, float y, float z)
    {
        gameObject.transform.Translate(x, y, z);
        return gameObject;
    }

    private GameObject Scale(GameObject gameObject,float x,float y,float z)
    {
        gameObject.transform.localScale.Scale(new Vector3(x, y, z));
        return gameObject;
    }


}
